///Murphy, Aqeel, Castilla (2026)///

clear all
cd "User specified directory"

///////////Table A2: ////////////////

//////Data: DHS data can be found and requested here: https://www.dhsprogram.com/methodology/survey/survey-display-566.cfm

* %%%% Table A2 CODE (includes some DHS cleaning code) %%%%
clear matrix
cap set maxvar 10000

* Women's File 
use "...\DHS\KEIR8AFL.dta", clear

gen dvagoout=v744a
gen dvanegkid=v744b
gen dvaargue=v744c
gen dvaifnosex=v744d
gen dvaburnfood=v744e

la var dvagoout "Believes IPV justified if woman goes out without telling him"
la var dvanegkid "Believes IPV justified if woman neglects child"
la var dvaargue "Believes IPV justified if woman argues"
la var  dvaifnosex "Believes IPV justified if woman refuses sex"
la var dvaburnfood "Believes IPV justified if woman burns food"

* Other key variables 
rename v025 urban
gen dvdrinks=d113

save  "woman_kenya_2022.dta", replace 

* Male File

use "...\DHS\KEMR8AFL.DTA", clear
ren mv744a male_dvagoout
ren mv744b male_dvanegkid
ren mv744c male_dvaargue
ren mv744d male_dvaifnosex
ren mv744e male_dvaburnfood

la var male_dvagoout "Believes IPV justified if woman goes out without telling him"
la var male_dvanegkid "Believes IPV justified if woman neglects child"
la var male_dvaargue "Believes IPV justified if woman argues"
la var male_dvaifnosex "Believes IPV justified if woman refuses sex"
la var male_dvaburnfood "Believes IPV justified if woman burns food"

** Merge men to women datafile **
isid v000 cluster hh spouse_line_no
merge 1:m v000 cluster hh spouse_line_no using "woman_kenya_2022.dta"

save "...\DHS\indiv_kenya_2022.dta", replace 

* %%%% Open merged file and create summary statistics %%%%%
  use "...DHS\indiv_kenya_2022.dta", clear

* Summary statistics for each
estpost summarize dvagoout dvanegkid dvaargue ///
 dvaifnosex dvaburnfood if urban==0 & dvdrinks==1, detail
 
esttab using "....tex", replace  ///
noobs cells("mean(fmt(3)) p50(fmt(3)) sd(fmt(3))") star(* 0.1 ** .05 *** 0.01) label plain fragment mlabels(,none) collabels(,none)

estpost summarize male_dvagoout male_dvanegkid ///
 male_dvaargue male_dvaifnosex male_dvaburnfood if urban==0 & drinks==1, detail

 esttab using "...tex", replace  ///
noobs cells("mean(fmt(3)) p50(fmt(3)) sd(fmt(3))") star(* 0.1 ** .05 *** 0.01) label plain fragment mlabels(,none) collabels(,none)